//
//  XLCometNetWorking.m
//  WebSocketTest
//
//  Created by tanqilong on 16/8/11.
//  Copyright © 2016年 tanqilong. All rights reserved.
//

#import "XLCometNetWorking.h"
#import "CMCometNetWorking.h"

@interface XLCometNetWorking ()
@property (nonatomic,strong) CMCometNetWorking * cometNet; //comet连接
@end

@implementation XLCometNetWorking

-(id)initCometWithParam:(NSDictionary *)dic LoadingFinished:(sucBlock)sucBlock Error:(errorBlock)errorBlock {
    self = [super init];
    if (self) {
        __weak typeof(self) ws = self;
        //获取请求后的状态
        self.sucBlock = sucBlock;
        self.errorBlock = errorBlock;
        self.cometNet = [CMCometNetWorking CometNetByUrl:[self getRequestUrl] paramDic:dic complete:^(id result) {
            [ws sucBlockDo:result];
        } Error:^(id error) {
            [ws errorBlockDo:error];
        }];
        [self.cometNet resume];
    }
    return self;
}

#pragma mark --方法
-(void)suspend {
    [self.cometNet suspend];
}

-(void)resume {
    [self.cometNet resume];
}

-(void)cancel {
    [self.cometNet cancel];
}

@end
